package com.fk.his.biznorule.service.executor;

import com.fk.his.biznorule.convertor.BizNoRuleConvertor;
import com.fk.his.biznorule.service.common.IApplicationExecutor;
import com.fk.his.domain.dservice.BizNoRuleDService;
import com.fk.his.domain.model.aggregates.BizNoRule;
import com.rickie.dto.data.BizNoRuleCO;
import com.rickie.dto.data.BizNoRuleAddCmd;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 规则增加执行器
 * <p>
 * 示例代码
 * <pre>
 *     一般而言，app模块中的Command Executor（命令处理程序）负责调用领域实体和Gateway进行编排实现简单业务，
 *     通过调用DomainService实现复杂业务场景。
 * </pre/>
 *
 * @author InHome
 * @version BME V100R001 2023/03/27
 * @since BME V100R001C40B104
 */
@Component
public class RuleAddExecutor implements IApplicationExecutor<BizNoRuleAddCmd, BizNoRuleCO> {

    @Autowired
    private BizNoRuleDService bizNoRuleDoMainService;

    @Override
    public BizNoRuleCO doExecute(BizNoRuleAddCmd param) {
        BizNoRule bizNoRule = BizNoRuleConvertor.toDomain(param);
        bizNoRule.saveOrUpdate();
//        bizNoRuleDoMainService.saveRule(bizNoRule);
        return BizNoRuleConvertor.toCO(bizNoRule);
    }
}